package andris.android.mobilarena.provider;

import java.util.ArrayList;

import com.viewpagerindicator.TitleProvider;

import andris.android.mobilarena.widget.BookmarkListFragment;
import andris.android.mobilarena.widget.MainListFragment;
import andris.android.mobilarena.widget.NewsFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class MainPagerAdapter extends FragmentPagerAdapter implements TitleProvider {

	private static final int NUM_FRAGMENTS = 3;
	private static final int MAIN_FRAGMENT_INDEX = 1;

	private ArrayList<Fragment> fragments;

	private static final String[] titles = new String[] { "kedvencek", "kiemelt", "hírek" };

	public MainPagerAdapter(FragmentManager fm) {
		super(fm);
		fragments = new ArrayList<Fragment>();
		fragments.add(new BookmarkListFragment());
		fragments.add(new MainListFragment());
		fragments.add(new NewsFragment());
	}

	@Override
	public Fragment getItem(int arg0) {
		return fragments.get(arg0);
	}

	@Override
	public int getCount() {
		return NUM_FRAGMENTS;
	}

	public int getCenter() {
		return MAIN_FRAGMENT_INDEX;
	}

	@Override
	public String getTitle(int position) {
		return titles[position];
	}

}
